package com.scott.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.scott.service.GeneratorService;
import com.scott.utils.PageHelperUtil;
import com.scott.utils.PageParams;
import com.scott.utils.R;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

/**
 * 工具类
 * Created by Scott on 2017/4/24.
 */
@RestController
@RequestMapping("/api")
public class GeneratorController {
    @Autowired
    GeneratorService generatorService;

    @RequestMapping(value = "/schema/findAll", method = RequestMethod.GET)
    public R getSchema() {
        return R.ok(generatorService.selectSchema());
    }

    @RequestMapping(value = "/schema/query", method = RequestMethod.POST)
    public R query(@RequestBody PageParams pageParams) {
        PageInfo<Map<String, Object>> pageInfo = generatorService.query(PageHelperUtil.convertPageParams(pageParams));

        return R.ok(pageInfo);
    }



}
